package com.woniuxy.controller;

import com.woniuxy.entity.ClassRoom;
import com.woniuxy.entity.Student;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @author 佘赛飞
 * @create 2021-11-23 1:13 下午
 */
/*
* 后端用list和数组，前段要用[]这个
* */
@RestController
public class JsonTestController {
    //对象
    @RequestMapping( value="/findOne",produces = "application/json;charset=UTF-8")
    public Student findOne(@RequestBody Student student) {
        System.out.println("JsonTestController.findOne"+student);
        return student;
    }
    //String
    @RequestMapping( value="/updateOne",produces = "application/json;charset=UTF-8")
    public String findOne(@RequestBody String student) {
        System.out.println("JsonTestController.findOne"+student);
        return student;
    }
    //数组
    @RequestMapping(value = "/findArray",produces = "application/json;charset=UTF-8")
    public int[] findArray(@RequestBody int[] array) {
      for (int i :array){
          System.out.println("JsonTestController.findArray"+i);
      }
      return array;
    }
    //List<Map <String,Object>>
    @RequestMapping(value = "/findListMap")
    public List<Map <String,Object>> findListMap(@RequestBody List<Map <String,Object>> mapList) {
     return mapList;
    }
    //map
    @RequestMapping(value = "/findMap")
    public Map <String, Object> findMap(@RequestBody Map <String, Object> map) {
        return map;
    }
    //对象list<map<String,实体类>>
   @RequestMapping(value = "findClassRoom")
    public ClassRoom findClassRoom(@RequestBody ClassRoom classRoom){
      return classRoom;
    }
}
